<fieldset>
    <legend>条件搜索</legend>
    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">培训名称</label>
            <div class="layui-input-inline" style="width:120px;">
                <input name="class_name" value="{:input('class_name','')}" placeholder="请输入班级名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">学员姓名</label>
            <div class="layui-input-inline" style="width:120px;">
                <input name="name" value="{:input('name','')}" placeholder="请输入学员姓名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">添加时间</label>
            <div class="layui-input-inline">
                <input maxlength="64" value="{:input('time_span','')}" data-date-range placeholder="请在这里输入报名时间" name='time_span' class="layui-input">
            </div>
        </div>
        <div class="block">
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">企业名称</label>
                <div class="layui-input-inline" style="width:120px;">
                    <input maxlength="64" value="{:input('company','')}" placeholder="请在这里输入企业名称" name='company' class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">分配班级</label>
                <div class="layui-input-inline" style="width:120px;">
                    <input maxlength="64" value="{:input('room_no','')}" placeholder="请在这里输入分配班级" name='room_no' class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
            </div>
            <div class="layui-form-item layui-inline">
                <button name="btn-export" class="layui-btn margin-left-10" type="button">
                    <i class="layui-icon layui-icon-export"></i>
                    <span> 导出学时信息</span>
                </button>
            </div>
            <div class="layui-form-item layui-inline">
                <input type="hidden" name="upload-enroll" value="" />
                <button name="btn-import" data-title="上传文件" data-file="btn"  data-field="upload-enroll"
                        class="layui-btn margin-left-10" type="button">
                    <i class="fa fa-cloud-upload"> </i>
                    <span> 导入学时信息</span>
                </button>
                <a target="_blank" style="position:absolute;right:16px;top:29px;"
                   href="/excel/eduenrollhour.xlsx">下载模板文件</a>
            </div>
        </div>
    </form>
</fieldset>

<script>window.form.render()</script>
<script>
    $("button[name=btn-export]").click(function () {
        var name = $("input[name=name]").val();
        var class_name = $("input[name=class_name]").val();
        var time_str = $("input[name=time_str]").val();
        var company = $("input[name=company]").val();
        var room_no = $("input[name=room_no]").val();
        location.href = '/cms/eduhour/export.html?name='+name+"&class_name="+class_name
            +"&time_str="+time_str+"&company="+company+"&room_no="+room_no;
    });
    $("input[name=upload-box]").change(function () {
        var url = $(this).val();
        $.ajax({type : "POST",url : "/cms/eduenroll/import.html",data : {"url":url},
            success : function(result) {
                if(result.code==1){
                    layer.msg(result.info, {time: 3000});
                    location.reload();
                }else{
                    layer.msg(result.info, {time: 3000});
                }
            },error : function(e){
                layer.msg(e.responseText, {time: 5000});
            }
        });
    });
    $("input[name=upload-enroll]").change(function () {
        var url = $(this).val();
        $.ajax({type : "POST",url : "/cms/eduhour/import.html",data : {"url":url},
            success : function(result) {
                if(result.code==1){
                    layer.msg(result.info, {time: 3000});
                    location.reload();
                }else{
                    layer.msg(result.info, {time: 3000});
                }
            },
            error:function(e){
                layer.msg(e.responseText, {time: 5000});
            }
        });
    });
</script>